package com.base.component.ai.system.converter;

import java.util.ArrayList;
import java.util.List;

import com.base.component.ai.workflow.flow.Flow;
import com.base.component.ai.workflow.flow.FlowFactory;
import com.base.core.head.converter.ListClassConverterEditor;
import com.gitee.magic.core.json.JsonArray;

/**
 * @author start 
 */
public class ListFlowConverterEditor extends ListClassConverterEditor {

	public ListFlowConverterEditor(Class<?> prototype) {
		super(Flow.class);
	}
	
	@Override
	public void restore(Object value) {
		if (value != null) {
			List<Flow> flows=new ArrayList<>();
			JsonArray jsonArray=new JsonArray(String.valueOf(value));
			for(int i=0;i<jsonArray.length();i++) {
				flows.add(FlowFactory.getFlow(jsonArray.getJsonObject(i)));
			}
			setValue(flows);
		}
	}
	
}
